package com.bdqn.servlet;

import com.alibaba.druid.sql.visitor.functions.Char;
import com.bdqn.entity.Chart;
import com.bdqn.entity.DepInfo;
import com.bdqn.service.DepartmentService;
import com.bdqn.service.Impl.DepartmentServiceImpl;
import com.bdqn.util.JSON;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "EchartServlet",urlPatterns = "/echart")
public class EchartServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        DepartmentService service = new DepartmentServiceImpl();
        List<DepInfo> info = service.findDepCount();
        JSON.writeAsString(info,response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
